package com.example.aics.config;

import java.util.List;
import java.util.Map;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import dev.langchain4j.mcp.McpToolProvider;
import dev.langchain4j.mcp.client.DefaultMcpClient;
import dev.langchain4j.mcp.client.McpClient;
import dev.langchain4j.mcp.client.transport.McpTransport;
import dev.langchain4j.mcp.client.transport.stdio.StdioMcpTransport;
/**
 * 高德地图MCP配置s
 */
@Configuration
public class GaoDeMapMCPConfig {

    @Bean
    public McpTransport gaoDeMapMcpTransport(){
        return new StdioMcpTransport.Builder()
        .command(List.of("npx", "-y","@amap/amap-maps-mcp-server"))
        .environment(Map.of("AMAP_MAPS_API_KEY",System.getenv("GAODE_MAP_API_KEY")))
        .logEvents(true)
        .build();
    }

    @Bean
    public McpClient gaoDeMapMcpClient(McpTransport gaoDeMapMcpTransport){
        return new DefaultMcpClient.Builder()
        .clientName("amap-demo")
        .transport(gaoDeMapMcpTransport)
        .build();
    }

    @Bean
    public McpToolProvider gaoDeMapMcpToolProvider(McpClient gaoDeMapMcpClient){
        return McpToolProvider.builder()
        .mcpClients(List.of(gaoDeMapMcpClient))
        .build();
    }

}
